import * as React from "react"
import { useHistory } from "react-router-dom"
import Captcha from "../../components/captcha"
import session, { LOGIN_CAPTCHA_CODE } from "../../session"

export default function CaptchaPage() {


  const history = useHistory()

  function handleRetrieveCaptcha() {
    // setCaptchaVisible(true)
    console.log("111")
  }

  function handleChangeCode(code: string) {
    session.set(LOGIN_CAPTCHA_CODE, code)
    history.goBack()
  }

  function handleClose() {
    session.remove(LOGIN_CAPTCHA_CODE)
    history.goBack()
  }

  return (
    <Captcha mobile="15688477267"
             retrieveDuration={60}
             onClose={handleClose}
             onChange={handleChangeCode}
             onRetrieve={handleRetrieveCaptcha}/>
  )
}
